# FROM findepi/graalvm:java17-native
# 上面的包不支持arm64
FROM openjdk:17.0.2-oraclelinux8

MAINTAINER lvwshuai

# 挂载目录
VOLUME /home/server
# 创建目录
RUN mkdir -p /home/server/jar \
    /home/server/temp \
    /home/server/db

WORKDIR /home/server

ENV SERVER_PORT=8080 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS=""

EXPOSE ${SERVER_PORT}

COPY ./jar/msw-admin.jar jar/msw-admin.jar
COPY ./db/msw_raw.db db/msw_raw.db

# 在 ENTRYPOINT 中获取 MAC 地址并启动 Java 应用
ENTRYPOINT MAC_ADDRESS=$(cat /host_sys/class/net/eth0/address) && \
           java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \
           -Dmac.address=${MAC_ADDRESS} -jar jar/msw-admin.jar ${JAVA_OPTS}